import {defineStore} from "pinia"
import {setToken} from "../utils/auth.js"

export const useUserStore = defineStore('user', {
	state: () => {
		return {
			// 用户信息
			userInfo: {
				avatar: null,
				username: null
			},
			// 登录状态
			loginStatus: false,
			// websocket状态
			wsStatus: false
		}
	},
	unistorage: true,	// 开启state数据持久化
	actions: {
		Login(formData) {
			return new Promise(
				(resolve) => {
					console.log(formData)
					setToken("gvim")
					resolve({loginStatus: true})
				},
				(reject) => {
					reject()
				}
			)
		}
	}
})